<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商家报表页面</title>
    <!--解决乱码问题-->
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <!--1.引入本地 Bootstrap 的样式-->
    <!--<link href="asserts/plugins/bootstrap/css/bootstrap.css" rel="stylesheet">-->
    <!--1.引入线上的 Bootstrap 的样式-->
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet">
    <!--2.引入 JQuery -->
    <script src="asserts/plugins/JQuery/jquery-2.1.1.min.js"></script>
    <script type="text/javascript"src="asserts/plugins/JQuery/jquery-2.1.1.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#selectAll_id").click(function () {
                $.ajax({
                    url:"/catering_system_app/finance/selectFinance",
                    //是否为异步
                    async:true,
                    type:"get",
                    data:{
                        shopid:$("#shopId").val(),
                        foodname:$("#food_name").val(),
                        categoryname:$("#category_name").val(),
                        orderAllPrice:$("#order_allPrice").val(),
                        orderCreatTime:$("#order_createTime").val()
                    },
                    dataType: 'json',
                    processData:false,
                    //指定为 false 才是正确的 Content-Type
                    contentType:false,

                    //回调成功执行的函数
                    success:function (financeVos) {
                        alert(financeVos.code);
                        if (financeVos.code= "200") {
                            var number;
                            var str = "<tr></tr>";
                            var allPrice=0.0;
                            if (financeVos.data!= null&&financeVos.data!="") {
                                for (var i = 0; i < financeVos.data.length; i++) {
                                    number = financeVos.data.length;
                                    str += "<tr style='padding-top: 10px'>" +
                                        "<td>" + financeVos.data[i].foodname + "</td>" +
                                        "<td>" + financeVos.data[i].categoryname + "</td>" +
                                        "<td>" + financeVos.data[i].orderAllPrice + "</td>" +
                                        "<td>"+formatDate(financeVos.data[i].orderCreatTime)+"</td>" +
                                    "</tr>";
                                    allPrice += financeVos.data[i].orderAllPrice ;
                                    $("#businessReport_List").html(str);
                                }
                            }else {
                                $("#businessReport_List").html(str);
                            }
                            $("#myprice").text("￥"+allPrice)
                        }
                    }
                })
                //时间戳转换
                function add0(m){return m<10?'0'+m:m }
                function formatDate(timestamp)
                {
                    //timestamp是整数，否则要parseInt转换
                    var time = new Date(timestamp);
                    var y = time.getFullYear();
                    var m = time.getMonth()+1;
                    var d = time.getDate();
                    var h = time.getHours();
                    var mm = time.getMinutes();
                    var s = time.getSeconds();
                    return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
                }
            })
        })

    </script>

</head>
<body>
    <!--头部-->
    <div class="row">
        <div class="col-md-1" style="border: 6px solid cadetblue;width: 100%;">
            <h3>我的报表</h3>
        </div>
    </div>
    <div></div><br>
<!------------------------------------------------------------------------------------------------>
    <!--选择栏-->
    <div class="div" >
        <div class="col-md-1" style="border:#6f8050;width: 100%;left: 50px;">
            <select style="width: 70px;height: 30px">
                <option>
                    <a id="all">全部</a>
                </option>
                <option>
                    <a id="pink">粉类</a>
                </option>
                <option>
                    <a id="meal ">饭类</a>
                </option>
                <option>
                    <a id="drinks">饮料类</a>
                </option>
            </select>
            <button id="selectAll_id">查询</button>
            <button name="day">日报</button>
            <button name="week">周报</button>
            <button name="month">月报</button>

        </div>
    </div>
    <div></div><br>

<!--------------------------表格头------------------------------------------>

    <table class="table table-bordered table-hover table-condensed">
        <thead>
        <div>
            <th>商品名</th>
            <th>商品类别</th>
            <th>收入</th>
            <th>时间</th>
        </div>
        </thead>
<!------------------------表尾----------------------------------------------------------->
        <tbody id="businessReport_List">

        </tbody>
    </table>
    <!--------------------总收入-------------->
    <div class="div">
        <div class="col-md-1" style="border:red;width: 100%;left: 650px;">
            <td>总收入：<em style="color: red" id="myprice"></em>￥</td>
        </div>
    </div>






</body>
</html>